﻿using System.Collections.Generic;
using System.Linq;
using DMS.BEs;
using DMS.Filters;

namespace DMS.DAOs.Memory
{
    public class InvoiceDAO : AbstractDAO<Invoice>, IInvoiceDAO
    {
        public IList<Invoice> GetByFilter(InvoiceFilter filter)
        {
            IEnumerable<Invoice> query = from i in Entities
                                         where
                                             (string.IsNullOrEmpty(filter.Country) ||
                                              filter.Country.Equals(i.BillingCountry)) &&
                                             (filter.CustomerId == 0 || filter.CustomerId.Equals(i.Customer))
                                         select i;
            return query.ToList();
        }
    }
}
